package cn.hnu.jpa.jpaExample.ManyToMany;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;

@Entity
public class MMSingleAddr implements Serializable {

	/**
	 * 多对多单向
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private String addr;
	//双向关联的时候用到
	private List<MMSingleCustomer> customers = new ArrayList<MMSingleCustomer>();
	
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}
	/**
	 * 一下为测试双向关系代码
	 */
	@ManyToMany(mappedBy="addrs" /* 可以选择是否加上cascade*/)
	@JoinColumn(name="addr_id")
	public List<MMSingleCustomer> getCustomers() {
		return customers;
	}

	public void setCustomers(List<MMSingleCustomer> customers) {
		this.customers = customers;
	}

	
	
	
}
